package com.kwok.hotel.es.db.application;

import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;

@SpringBootApplication
@ComponentScan("com.kwok.hotel.es.db")
@MapperScan("com.kwok.**.dao")
public class EsDbApplication {

    public static void main(String[] args) {
        SpringApplication.run(EsDbApplication.class, args);
    }

    @Bean
    public ElasticsearchRestTemplate elasticsearchRestTemplate(RestClientBuilder restClientBuilder){
        RestHighLevelClient restHighLevelClient = new RestHighLevelClient(restClientBuilder);
        ElasticsearchRestTemplate elasticsearchRestTemplate = new ElasticsearchRestTemplate(restHighLevelClient);
        return elasticsearchRestTemplate;
    }

}
